package com.java.threaddemo2;

public class Producter extends Thread {
	// 属性
	private WarehouseStack whStack;
	private boolean isStopped;// 多线程终止采用外部传入参数

	// 行为
	@Override
	public void run() {
		int num = 0;
		// while死循环
		while (true) {
			
				// 生产一个产品
				Product pro = new Product("" + (++num), (int) (Math.random() * 10 + 90));
				whStack.push(pro);// 入栈
				System.out.println("生产产品信息：" + pro.printInfo());
			
			try {
				Thread.sleep(250);// 休眠1s
			} catch (InterruptedException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}

		}

	}

	// 构造方法
	public Producter(WarehouseStack whStack) {
		this.whStack = whStack;
	}
	// getter，setter

	public WarehouseStack getWhStack() {
		return whStack;
	}

	public void setWhStack(WarehouseStack whStack) {
		this.whStack = whStack;
	}

	public boolean isStopped() {
		return isStopped;
	}

	public void setStopped(boolean isStopped) {
		this.isStopped = isStopped;
	}

}
